<template>
  <div class="filter-more">
    <div class="from_header">
      <el-form ref="form" label-width="120px">
        <el-form-item label="图纸名称：">
          <el-input
            v-model="searchInfo.picName"
            size="small"
            placeholder="请输入图纸名称"
          />
        </el-form-item>
        <el-form-item label="产品图号：">
          <el-input
            v-model="searchInfo.picCode"
            size="small"
            placeholder="请输入产品图号"
          />
        </el-form-item>
        <el-form-item label="是否外协：">
          <el-select
            v-model="searchInfo.isComplete"
            clearable
            placeholder="请选择"
          >
            <el-option
              v-for="item in completeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </el-form>

      <div v-if="isRouter" class="establish">
        <el-button
          type="primary"
          size="small"
          @click="workmanshipFile"
        >导入工艺</el-button
        >
        <el-button
          v-if="isOrderProduct"
          type="primary"
          size="small"
          @click="importFile"
        >导入</el-button
        >
        <el-button
          v-if="isOrderProduct"
          type="primary"
          size="small"
          @click="goback"
        >返回</el-button
        >
        <el-button
          v-if="isNosingle && isOrderProduct"
          type="primary"
          size="small"
          @click="single"
        >是否外协</el-button
        >
        <el-button
          type="primary"
          size="small"
          @click="newly"
        >新增</el-button
        >
        <el-button
          type="primary"
          size="small"
          @click="selected"
        >查询</el-button
        >
        <el-button plain size="small" @click="reset">重置</el-button>
      </div>
    </div>
  </div>
</template>

<script>
// import { Message } from 'element-ui';

export default {
  model: {
    prop: 'searchInfo'
  },
  props: {
    isNosingle: {
      type: Boolean,
      default() {
        return false
      }
    },
    isOrderProduct: {
      type: Boolean,
      default() {
        return false
      }
    }
  },
  data() {
    return {
      isRouter: !(
        window.sessionStorage.getItem('department') == 8 ||
					window.sessionStorage.getItem('department') == 10
      ),
      completeList: [
        {
          label: '否',
          value: '0'
        },
        {
          label: '是',
          value: '1'
        }
      ],
      searchInfo: {
        isComplete: '',
        picName: '',
        picCode: ''
      }
    }
  },
  mounted() {},
  methods: {
    importFile() {
      this.$emit('importFile')
    },
    workmanshipFile() {
      this.$emit('workmanshipFile')
    },
    single() {
      this.$emit('single')
    },
    goback() {
      this.$emit('goback')
    },
    selected() {
      this.$emit('selected', this.searchInfo)
    },
    // 重置
    reset() {
      this.searchInfo = {
        isComplete: '',
        picCode: '',
        picName: ''
      }
      this.selected()
    },
    // 新增弹框
    newly() {
      this.$emit('add')
    }
  }
}
</script>

<style scoped lang="scss">
.filter-more {
	// width: 90%;
	// margin: 0 auto;
	display: flex;
	flex-direction: column;
	// background: #ccc;
	// border: 1px solid #e8f4fd;
	// padding: 25px 15px;
	.from_header {
		width: 100%;
		height: 100%;

		.el-form-item {
			margin: 10px 30px;
		}

		.el-form {
			width: 100%;
			display: flex;
			flex-wrap: wrap;
		}
		/deep/ .el-form-item__content {
			display: flex;
		}
	}
	.establish {
		float: right;
	}
}
</style>
